<template>
  <section @click="sendDateTime">点击我发送当前时间</section>
</template>
<script lang="ts" setup>
const dateTimeChannel = new BroadcastChannel('dateTimeChannel')

function sendDateTime() {
  const d = new Date()
  const date = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
  const time = `${d.getHours()}:${d.getMinutes() + 1}:${d.getSeconds()}`
  const msg = date + ' ' + time
  dateTimeChannel.postMessage(msg)
}
</script>
<style lang="scss" scoped></style>
